package com.flymobi.mshop.activity;

import java.util.List;
import java.util.Map;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.flymobi.mshop.R;
import com.flymobi.mshop.util.service.DilivTypeService;
import com.flymobi.mshop.util.service.PayTypeService;

public class ShouHuoRen extends CommonActivity {
	private EditText editren;
	private EditText editshouji;
	private EditText editdizhi;
	private EditText edityoubian;
	private Button btnadd;
	private Button btnding;
	private List<Map<String, Object>> zflist;
	private List<Map<String, Object>> pslist;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.shouhuoren);
		Init();
		btnding.setOnClickListener(new okClick());
		btnadd.setOnClickListener(new addClick());
	}

	class addClick implements OnClickListener {
		@Override
		public void onClick(View v) {

		}
	}

	class okClick implements OnClickListener {
		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			if (editren.getText().equals("") && editshouji.getText().equals("")
					&& editdizhi.getText().equals("")
					&& edityoubian.getText().equals("")) {
				Toast.makeText(ShouHuoRen.this, "请填写收款人信息", 1000);
			} else {
				zflist = PayTypeService.list();
				pslist = DilivTypeService.list();
				FillOrder.valueMap.put("name", editren.getText().toString());
				FillOrder.valueMap.put("shouji", editshouji.getText()
						.toString());
				FillOrder.valueMap.put("dizhi", editdizhi.getText().toString());
				FillOrder.valueMap.put("youbian", edityoubian.getText()
						.toString());
				FillOrder.valueMap.put("zhifu", zflist.get(0).get("name")
						.toString());
				FillOrder.valueMap.put("peisong", pslist.get(0).get("name")
						.toString());
				FillOrder.valueMap.put("type", "普通发票");
				FillOrder.valueMap.put("danwei", "个人");
				FillOrder.valueMap.put("danweiname", "");
				FillOrder.valueMap.put("leixing", "电器");
				Intent intent = new Intent();
				intent.setClass(ShouHuoRen.this, FillOrder.class);
				ShouHuoRen.this.startActivity(intent);
			}
		}
	}

	private void Init() {
		editren = (EditText) findViewById(R.id.editren);
		editshouji = (EditText) findViewById(R.id.editshouji);
		editdizhi = (EditText) findViewById(R.id.editdizhi);
		edityoubian = (EditText) findViewById(R.id.edityoubian);
		btnadd = (Button) findViewById(R.id.btnadd);
		btnding = (Button) findViewById(R.id.btnding);
	}
}
